<!---
Copyright (c) 2007 Brian Billman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--->
<cfcomponent displayname="CFSmugAlbums" output="false" extends="CFSmugBase">

	<cffunction name="get" access="public" output="false" returntype="array" hint="This method returns a list of albums for a given user (either via SessionID or (optional) NickName). If the session is logged in as the requested user, a complete list of albums is returned. Otherwise, only the public albums are returned.">
		<cfargument name="SessionID" type="string" required="true" />
		<cfargument name="NickName" type="string" required="false" hint="Required if an anonymous SessionID" />
		<cfargument name="Heavy" type="boolean" required="false" default="false" hint="Different results returned based on SessionID" />
		<cfargument name="SitePassword" type="string" required="false" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.get ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albums.get",
											  args = argsCopy,
										  	  secureMode = StructKeyExists( Arguments, "SitePassword" ) )  />

		<cfreturn convertResponse( response ) />
	</cffunction>

	<cffunction name="getInfo" access="public" output="false" returntype="struct" hint="This method returns detailed information about the album specified by AlbumID. If the album isn't owned by the Session holder and also isn't public or has a password, an 'invalid user' error will be returned. Note that many of the fields are protected for the owner's eyes only. Reduced information is provided to a non-owner.">
		<cfargument name="SessionID" type="string" required="true" />
		<cfargument name="AlbumID" type="numeric" required="true" />
		<cfargument name="Password" type="string" required="false" />
		<cfargument name="SitePassword" type="string" required="false" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />
		<cfset var passwordExists = false />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.getInfo ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albums.getInfo",
											  args = argsCopy,
										  	  secureMode = passwordExists )  />

		<cfreturn convertResponse( response ) />
	</cffunction>

	<cffunction name="create" access="public" output="false" returntype="numeric" hint="This method will create an album in the specified category (identified by the CategoryID) with the specified Title. The session must be established with a valid login. Optionally, other arguments may be specified that adjust specific album properties. Returns the AlbumID for the created album.">
		<cfargument name="SessionID" type="string" required="true" />
		<!--- essentials --->
		<cfargument name="Title" type="string" required="true" />
		<cfargument name="CategoryID" type="numeric" required="true" />
		<!--- optional arguments, will get default values from smugmug if not passed in --->
		<cfargument name="AlbumTemplateID" type="numeric" required="false" hint="Default: 0. Use a pre-made album template? Overrides all other settings which templates can control." />
		<!--- extras --->
		<cfargument name="SubCategoryID" type="numeric" required="false" hint="Default: 0. Does this album belong to a SubCategory?" />
		<cfargument name="Description" type="string" required="false" hint="Text description of the contents of the album" />
		<cfargument name="Keywords" type="string" required="false" hint="Any keywords used to search or describe the album" />
		<cfargument name="Geography" type="boolean" required="false" hint="Default: TRUE. Show and use the mapping features?" />
		<!--- look & feel --->
		<cfargument name="ThemeID" type="numeric" required="false" hint="Default: 0. Select a theme for the album." />
		<cfargument name="Clean" type="boolean" required="false" hint="Default: FALSE. Display album in Clean style?" />
		<cfargument name="EXIF" type="boolean" required="false" hint="Default: TRUE. Display extended camera information?" />
		<cfargument name="Filenames" type="boolean" required="false" hint="Default: FALSE. Show filenames if no caption?" />
		<cfargument name="SortMethod" type="string" required="false" hint="The method by which to sort the photos when displaying them.  Default: 'Position'. Valid values: 'Position': Sorts by user-specified position; 'Caption': Sorts by the image captions; 'FileName': Sorts by the filename of each photo; 'Date': Sorts by the date uploaded to smugmug; 'DateTime': Sorts by the date last modified, as told by EXIF data. Many files don't have this field correctly set; 'DateTimeOriginal': Sorts by the date taken, as told by EXIF data. Many cameras don't report this properly." />
		<cfargument name="SortDirection" type="boolean" required="false" hint="Default: FALSE (Ascending). Which direction to order the SortMethod. Valid values: FALSE: Ascending (1-99, A-Z, 1980-2004, etc); TRUE: Descending (99-1, Z-A, 2004-1980, etc)" />
		<cfargument name="Position" type="numeric" required="false" hint="Default: 1. The album's position within it's Category/SubCategory, starting with 1 at the top" />
		<cfargument name="Header" type="boolean" required="false" hint="Default: FALSE. POWER+PRO ONLY! Display custom header, if any?" />
		<cfargument name="TemplateID" type="numeric" required="false" hint="Default: 0. POWER+PRO ONLY! Force a display style? Possible values: Viewer Choice (Recommended!): 0; SmugMug: 3; SmugMug Small: 10; Traditional: 4; All Thumbs: 7; Slideshow: 8; Journal: 9; Filmstrip: 11" />
		<!--- security & privacy --->
		<cfargument name="Password" type="string" required="false" hint="Optional password to protect this album" />
		<cfargument name="PasswordHint" type="string" required="false" hint="Optional, gives your visitors a hint" />
		<cfargument name="Public" type="boolean" required="false" hint="Default: TRUE. Is this album public?" />
		<cfargument name="WorldSearchable" type="boolean" required="false" hint="Default: TRUE. Want your gallery searchable via search engines?" />
		<cfargument name="SmugSearchable" type="boolean" required="false" hint="Default: TRUE. Want your gallery searchable by other SmugMuggers?" />
		<cfargument name="External" type="boolean" required="false" hint="Default: TRUE. Allow external linking?" />
		<cfargument name="HideOwner" type="boolean" required="false" hint="Default: FALSE. Mask the URL & name of the owner?" />
		<cfargument name="Larges" type="boolean" required="false" hint="Default: TRUE. PRO ONLY! Allow Large photos to be seen?" />
		<cfargument name="XLarges" type="boolean" required="false" hint="Default: TRUE. Allow XLarge photos to be seen?" />
		<cfargument name="X2Larges" type="boolean" required="false" hint="Default: TRUE. Allow X2Large photos to be seen?" />
		<cfargument name="X3Larges" type="boolean" required="false" hint="Default: TRUE. Allow X3Large photos to be seen?" />
		<cfargument name="Originals" type="boolean" required="false" hint="Default: TRUE. Allow Original photos to be seen?" />
		<cfargument name="Protected" type="boolean" required="false" hint="Default: FALSE. PRO ONLY! Enable heavy image protection?" />
		<cfargument name="Watermarking" type="boolean" required="false" hint="Default: FALSE. PRO ONLY! Enabled watermarking of photos?" />
		<!--- social --->
		<cfargument name="CanRank" type="boolean" required="false" hint="Default: TRUE. Allow visitors to vote your photos most popular?" />
		<cfargument name="FriendEdit" type="boolean" required="false" hint="Default: FALSE. Allow Friends to edit captions & keywords?" />
		<cfargument name="FamilyEdit" type="boolean" required="false" hint="Default: FALSE. Allow Family to edit captions & keywords?" />
		<cfargument name="Comments" type="boolean" required="false" hint="Default: TRUE. Allow comments?" />
		<cfargument name="Share" type="boolean" required="false" hint="Default: TRUE. Enable 'easy sharing' button and features?" />
		<!--- printing & sales --->
		<cfargument name="Printable" type="boolean" required="false" hint="Default: TRUE. Allow prints to be purchased?" />
		<cfargument name="DefaultColor" type="boolean" required="false" hint="Default: TRUE. PRO ONLY! In the cart, default to True or AutoColor? True Color: FALSE; Auto Color: TRUE" />
		<cfargument name="ProofDays" type="numeric" required="false" hint="Default: 0. PRO ONLY! Delay printing for up to 7 business days?" />
		<cfargument name="Backprinting" type="string" required="false" hint="PRO ONLY! Want something printed on the backs of prints?" />
		<cfargument name="UnsharpAmount" type="numeric" required="false" hint="Default: 0.200. PRO+POWER ONLY!" />
		<cfargument name="UnsharpRadius" type="numeric" required="false" hint="Default: 1.000. PRO+POWER ONLY!" />
		<cfargument name="UnsharpThreshold" type="numeric" required="false" hint="Default: 0.050. PRO+POWER ONLY!" />
		<cfargument name="UnsharpSigma" type="numeric" required="false" hint="Default: 1.000. PRO+POWER ONLY!" />
		<!--- community --->
		<cfargument name="CommunityID" type="numeric" required="false" hint="Default: 0. Is this album a part of a community?" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.create ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albums.create",
											  args = argsCopy,
										  	  secureMode = StructKeyExists( Arguments, "Password" ) )  />

		<cfreturn convertResponse( response ) />
	</cffunction>

	<cffunction name="changeSettings" access="public" output="false" returntype="void" hint="This method will change the settings on an album specified by AlbumID. The session must be established with a valid login. All settings are optional, if omitted, the current value for that setting is preserved.">
		<cfargument name="SessionID" type="string" required="true" />
		<cfargument name="AlbumID" type="numeric" required="true" />
		<!--- essentials --->
		<cfargument name="Title" type="string" required="false" />
		<cfargument name="CategoryID" type="numeric" required="false" hint="Default: 0. Which Category does this Album belong to?" />
		<!--- optional arguments, will get default values from smugmug if not passed in --->
		<cfargument name="AlbumTemplateID" type="numeric" required="false" hint="Default: 0. Use a pre-made album template? Overrides all other settings which templates can control." />
		<!--- extras --->
		<cfargument name="SubCategoryID" type="numeric" required="false" hint="Default: 0. Does this album belong to a SubCategory?" />
		<cfargument name="Description" type="string" required="false" hint="Text description of the contents of the album" />
		<cfargument name="Keywords" type="string" required="false" hint="Any keywords used to search or describe the album" />
		<cfargument name="Geography" type="boolean" required="false" hint="Default: TRUE. Show and use the mapping features?" />
		<!--- look & feel --->
		<!--- TODO: ThemeID doesn't work for updateSettings, only for create? Seems to have no effect. --->
		<cfargument name="ThemeID" type="numeric" required="false" hint="Default: 0. Select a theme for the album." />
		<cfargument name="Clean" type="boolean" required="false" hint="Default: FALSE. Display album in Clean style?" />
		<cfargument name="EXIF" type="boolean" required="false" hint="Default: TRUE. Display extended camera information?" />
		<cfargument name="Filenames" type="boolean" required="false" hint="Default: FALSE. Show filenames if no caption?" />
		<cfargument name="SortMethod" type="string" required="false" hint="The method by which to sort the photos when displaying them.  Default: 'Position'. Valid values: 'Position': Sorts by user-specified position; 'Caption': Sorts by the image captions; 'FileName': Sorts by the filename of each photo; 'Date': Sorts by the date uploaded to smugmug; 'DateTime': Sorts by the date last modified, as told by EXIF data. Many files don't have this field correctly set; 'DateTimeOriginal': Sorts by the date taken, as told by EXIF data. Many cameras don't report this properly." />
		<cfargument name="SortDirection" type="boolean" required="false" hint="Default: FALSE (Ascending). Which direction to order the SortMethod. Valid values: FALSE: Ascending (1-99, A-Z, 1980-2004, etc); TRUE: Descending (99-1, Z-A, 2004-1980, etc)" />
		<cfargument name="Position" type="numeric" required="false" hint="Default: 1. The album's position within it's Category/SubCategory, starting with 1 at the top" />
		<cfargument name="HighlightID" type="numeric" required="false" hint="Default: 0. The ImageID of the photo to be highlighted" />
		<cfargument name="Header" type="boolean" required="false" hint="Default: FALSE. POWER+PRO ONLY! Display custom header, if any?" />
		<cfargument name="TemplateID" type="numeric" required="false" hint="Default: 0. POWER+PRO ONLY! Force a display style? Possible values: Viewer Choice (Recommended!): 0; SmugMug: 3; SmugMug Small: 10; Traditional: 4; All Thumbs: 7; Slideshow: 8; Journal: 9; Filmstrip: 11" />
		<!--- security & privacy --->
		<cfargument name="Password" type="string" required="false" hint="Optional password to protect this album" />
		<cfargument name="PasswordHint" type="string" required="false" hint="Optional, gives your visitors a hint" />
		<cfargument name="Public" type="boolean" required="false" hint="Default: TRUE. Is this album public?" />
		<cfargument name="WorldSearchable" type="boolean" required="false" hint="Default: TRUE. Want your gallery searchable via search engines?" />
		<cfargument name="SmugSearchable" type="boolean" required="false" hint="Default: TRUE. Want your gallery searchable by other SmugMuggers?" />
		<cfargument name="External" type="boolean" required="false" hint="Default: TRUE. Allow external linking?" />
		<cfargument name="HideOwner" type="boolean" required="false" hint="Default: FALSE. Mask the URL & name of the owner?" />
		<cfargument name="Larges" type="boolean" required="false" hint="Default: TRUE. PRO ONLY! Allow Large photos to be seen?" />
		<cfargument name="XLarges" type="boolean" required="false" hint="Default: TRUE. Allow XLarge photos to be seen?" />
		<cfargument name="X2Larges" type="boolean" required="false" hint="Default: TRUE. Allow X2Large photos to be seen?" />
		<cfargument name="X3Larges" type="boolean" required="false" hint="Default: TRUE. Allow X3Large photos to be seen?" />
		<cfargument name="Originals" type="boolean" required="false" hint="Default: TRUE. Allow Original photos to be seen?" />
		<cfargument name="Protected" type="boolean" required="false" hint="Default: FALSE. PRO ONLY! Enable heavy image protection?" />
		<cfargument name="Watermarking" type="boolean" required="false" hint="Default: FALSE. PRO ONLY! Enabled watermarking of photos?" />
		<!--- social --->
		<cfargument name="CanRank" type="boolean" required="false" hint="Default: TRUE. Allow visitors to vote your photos most popular?" />
		<cfargument name="FriendEdit" type="boolean" required="false" hint="Default: FALSE. Allow Friends to edit captions & keywords?" />
		<cfargument name="FamilyEdit" type="boolean" required="false" hint="Default: FALSE. Allow Family to edit captions & keywords?" />
		<cfargument name="Comments" type="boolean" required="false" hint="Default: TRUE. Allow comments?" />
		<cfargument name="Share" type="boolean" required="false" hint="Default: TRUE. Enable 'easy sharing' button and features?" />
		<!--- printing & sales --->
		<cfargument name="Printable" type="boolean" required="false" hint="Default: TRUE. Allow prints to be purchased?" />
		<cfargument name="DefaultColor" type="boolean" required="false" hint="Default: TRUE. PRO ONLY! In the cart, default to True or AutoColor? True Color: FALSE; Auto Color: TRUE" />
		<cfargument name="ProofDays" type="numeric" required="false" hint="Default: 0. PRO ONLY! Delay printing for up to 7 business days?" />
		<cfargument name="Backprinting" type="string" required="false" hint="PRO ONLY! Want something printed on the backs of prints?" />
		<cfargument name="UnsharpAmount" type="numeric" required="false" hint="Default: 0.200. PRO+POWER ONLY!" />
		<cfargument name="UnsharpRadius" type="numeric" required="false" hint="Default: 1.000. PRO+POWER ONLY!" />
		<cfargument name="UnsharpThreshold" type="numeric" required="false" hint="Default: 0.050. PRO+POWER ONLY!" />
		<cfargument name="UnsharpSigma" type="numeric" required="false" hint="Default: 1.000. PRO+POWER ONLY!" />
		<!--- community --->
		<cfargument name="CommunityID" type="numeric" required="false" hint="Default: 0. Is this album a part of a community?" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.changeSettings ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albums.changeSettings",
											  args = argsCopy,
										  	  secureMode = StructKeyExists( Arguments, "Password" ) )  />

		<cfset convertResponse( response ) />
		<cfreturn />
	</cffunction>

	<cffunction name="delete" access="public" output="false" returntype="boolean" hint="This method deletes the specified Album and all photos within.">
		<cfargument name="SessionID" type="string" required="true" />
		<cfargument name="AlbumID" type="numeric" required="true" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.delete ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albums.delete",
											  args = argsCopy )  />

		<cfreturn convertResponse( response ) />
	</cffunction>

	<cffunction name="reSort" access="public" output="false" returntype="boolean" hint="This method will re-sort all the photos inside of the album specified by AlbumID. Note that this is a one-time event, and doesn't apply directly to images added in the future by other means.">
		<cfargument name="SessionID" type="string" required="true" />
		<cfargument name="AlbumID" type="numeric" required="true" />
		<cfargument name="By" type="string" required="true" hint="Current valid values: FileName, Caption, DateTime" />
		<cfargument name="Direction" type="string" required="false" default="ASC" hint="Valid values: ASC, DESC" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.reSort ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albums.reSort",
											  args = argsCopy )  />

		<cfreturn convertResponse( response ) />
	</cffunction>

	<cffunction name="getStats" access="public" output="false" returntype="struct" hint="Gets transfer statitistics for the given Album during the given Month and Year. SmugMug often only keeps the last few months (current + 2 previous), but you never know. A float is provided for Originals because videos often are only partially viewed. If 'Heavy' is set to '1', an array of images with each image transfer stat (just like smugmug.images.getStats) is provided for each album in addition to the album stats.">
		<cfargument name="SessionID" type="string" required="true" />
		<cfargument name="AlbumID" type="numeric" required="true" />
		<cfargument name="Month" type="numeric" required="true" />
		<cfargument name="Year" type="numeric" required="true" />
		<cfargument name="Heavy" type="boolean" required="false" default="false" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.getStats ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albums.getStats",
											  args = argsCopy )  />

		<cfreturn convertResponse( response ) />
	</cffunction>

	<cffunction name="getAlbumTemplates" access="public" output="false" returntype="array" hint="This method returns all of the album templates for the logged in user (via SessionID).">
		<cfargument name="SessionID" type="string" required="true" />

		<cfset var response = 0 />
		<cfset var argsCopy = structNew() />

		<cfset argsCopy = createSmugMugArgs( functionMetadata = getMetaData( this.getAlbumTemplates ), argsPassed = Arguments ) />

		<cfset response = doRemoteInvocation( method = "smugmug.albumtemplates.get",
											  args = argsCopy )  />

		<cfreturn convertResponse( response ) />
	</cffunction>

	<cffunction name="convertResponse" access="private" output="false" returntype="any">
		<cfargument name="responseXML" type="xml" required="true" />
		<cfset var x = 0 />
		<cfset var s = 0 />
		<cfset var c1 = 0 />

		<cftry>

			<cfif validateRESTResponse( Arguments.responseXML )>
				<cfset x = Arguments.responseXML.rsp />
			</cfif>

			<cfswitch expression="#LCase( x.method.XmlText )#">

				<cfcase value="smugmug.albums.get">
					<!---
						Array of structs: [empty array if no albums]
							int "AlbumID"
							String "Title"
							String "Category"
							int "CategoryID"
							String "SubCategory" optional
							int "SubCategoryID" optional
					--->


					<cfset s = ArrayNew( 1 ) />
					<cfif StructKeyExists( x, "Albums" ) And ArrayLen( x.Albums.Album )>
						<cfloop from="1" to="#ArrayLen( x.Albums.Album )#" index="c1">
							<cfset s[c1] = createAlbumStruct( AlbumNode = x.Albums.Album[c1] ) />
						</cfloop>
					</cfif>
				</cfcase>

				<cfcase value="smugmug.albums.getInfo">
					<!---
						struct
							int "AlbumID"
							int "HighlightID"
							int "CategoryID"
							int "SubCategoryID"
							int "Position"
							String "SortMethod" - Owner only
							boolean "SortDirection" - Owner only
							int "ImageCount"
							String "Title"
							String "Description"
							String "LastUpdated"
							int "CommunityID" - Owner only
							boolean "Public" - Owner only
							String "Password" - Owner only
							boolean "Printable" - Owner only
							boolean "Filenames" - Owner only
							boolean "Comments" - Owner only
							boolean "External" - Owner only
							boolean "Originals" - Owner only
							boolean "FamilyEdit" - Owner only
							boolean "FriendEdit" - Owner only
							boolean "HideOwner" - Owner only
							boolean "EXIF" - Owner only
							boolean "Share" - Owner only
							boolean "Header" - Owner only, Power+Pro only!
							int "TemplateID" - Owner only, Power+Pro only!
							boolean "Larges" - Owner only, Pro only!
							boolean "XLarges" - Owner only,	Pro only!
							boolean "X2Larges" - Owner only
							boolean "X3Larges" - Owner only
							boolean "DefaultColor" - Owner only, Pro only!
							boolean "Clean" - Owner only
							boolean "Protected" - Owner only, Pro only!
							boolean "Watermarking" - Owner only, Pro only!
							int "WatermarkID" - Owner only, Pro only!
							boolean "SmugSearchable" - Owner only
							float "UnsharpAmount" - Owner only, Power+Pro only!
							float "UnsharpRadius" - Owner only, Power+Pro only!
							float "UnsharpThreshold" - Owner only, Power+Pro only!
							float "UnsharpSIgma" - Owner only, Power+Pro only!
							boolean "WorldSearchable" - Owner only
					--->

					<cfset s = createAlbumStruct( AlbumNode = x.Album ) />

				</cfcase>

				<cfcase value="smugmug.albums.create">
					<!---
						int AlbumID
					--->

					<cfset s = x.Album.xmlAttributes.id />
				</cfcase>

				<cfcase value="smugmug.albums.changeSettings">
					<!---
						void? return true
					--->

					<cfset s = true />
				</cfcase>

				<cfcase value="smugmug.albums.delete;smugmug.albums.reSort" delimiters=";">
					<!---
						boolean Album
					--->

					<cfset s = true />
				</cfcase>

				<cfcase value="smugmug.albums.getStats">
					<!---
						Array of structs: (Albums)
							int AlbumID
							int Bytes
							int Tiny
							int Thumb
							int Small
							int Medium
							int Large
							float Original
								Array of structs: (Images, if any exist)
									int ImageID
									int Bytes
									int Tiny
									int Thumb
									int Small
									int Medium
									int Large
									float Original
					--->

					<!--- create struct for album stats --->
					<cfset s = createStatsStruct( StatsNode = x.Album, ForAlbum = true ) />

					<cfif StructKeyExists( x.Album, "Images" )>
						<cfset s["Images"] = ArrayNew( 1 ) />
						<cfif ArrayLen( x.Album.Images.Image )>
							<!--- create struct for stats for each image --->
							<cfloop from="1" to="#ArrayLen( x.Album.Images.Image )#" index="c1">
								<cfset s["Images"][c1] = createStatsStruct( StatsNode = x.Album.Images.Image[c1], ForAlbum = false ) />
							</cfloop>
						</cfif>
					</cfif>

				</cfcase>

				<cfcase value="smugmug.albumtemplates.get">
					<!---
						Array of structs: ("AlbumTemplates")
							int "id"
							String "AlbumTemplateName"
							int "HighlightID"
							String "SortMethod"
							boolean "SortDirection"
							boolean "Public"
							String "Password"
							String "PasswordHint"
							boolean "Printable"
							boolean "Filenames"
							boolean "Comments"
							boolean "External"
							boolean "Originals"
							boolean "EXIF"
							boolean "Share"
							boolean "Header"
							boolean "Larges"
							boolean "XLarges"
							boolean "X2Larges"
							boolean "X3Larges"
							boolean "Clean"
							boolean "Protected"
							boolean "Watermarking"
							boolean "FamilyEdit"
							boolean "FriendEdit"
							boolean "HideOwner"
							boolean "DefaultColor"
							boolean "Geography"
							boolean "CanRank"
							int "ProofDays"
							String "Backprinting"
							boolean "SmugSearchable"
							float "UnsharpAmount"
							float "UnsharpRadius"
							float "UnsharpThreshold"
							float "UnsharpSigma"
							boolean "WorldSearchable"
							struct: "Template"
								int id
							struct: "Community"
								int id
							struct: "Watermark"
								int id
					--->

					<cfset s = ArrayNew( 1 ) />
					<cfloop from="1" to="#ArrayLen( x.AlbumTemplates.AlbumTemplate )#" index="c1">
						<cfset s[c1] = StructNew() />
						<cfset StructAppend( s[c1], x.AlbumTemplates.AlbumTemplate[c1].XmlAttributes ) />
						<cfset s[c1]["AlbumTemplateID"] = s[c1].id />
						<cfset StructDelete( s[c1], "id" ) />

						<cfset s[c1]["TemplateID"] = x.AlbumTemplates.AlbumTemplate[c1].Template.XmlAttributes.id />
						<cfset s[c1]["CommunityID"] = x.AlbumTemplates.AlbumTemplate[c1].Community.XmlAttributes.id />
						<cfset s[c1]["WatermarkID"] = x.AlbumTemplates.AlbumTemplate[c1].Watermark.XmlAttributes.id />
					</cfloop>
				</cfcase>


				<cfdefaultcase>
					<cfset logAction( file="CFSmug.CFSmugAlbums.convertResponse", text="Message = Received response from unexpected method: '#x.method.XmlText#'", type="Warning" ) />
					<cfthrow type="CFSmug.CFSmugAlbums.convertResponse" message="Received response from unexpected method: '#x.method.XmlText#'" />
				</cfdefaultcase>

			</cfswitch>

			<cfreturn s />


			<cfcatch type="CFSmug">
				<cfrethrow />
			</cfcatch>
			<cfcatch type="any">
				<cfset logAction( file="CFSmug.CFSmugAlbums.convertResponse", text="Error converting response; Message=#cfcatch.message#; Detail=#cfcatch.detail#; Stacktrace=#cfcatch.stacktrace#", type="Error" ) />
				<cfthrow type="CFSmug.CFSmugAlbums.convertResponse"
						message="Error converting response" detail="Message: #cfcatch.message#; Detail: #cfcatch.detail#" />
			</cfcatch>
		</cftry>
	</cffunction>

</cfcomponent>